import React, {useEffect, useState} from 'react';
import axios from "axios";
import {
    Link
} from "react-router-dom";

function UserList(props) {
    const [userList,setUserList] = useState([]);
    useEffect(()=>{
        axios.get("http://zhangpeiyue.com/scoreList").then(res=>{
            setUserList(res.data);
        })
    },[])
    return (
        <div>
            <h3>用户列表界面</h3>
            {
                userList.map(item=>(
                    <p key={item.id}>
                       <Link to={"/userDetails/"+item.id+".html"}>{item.userName}</Link>
                    </p>
                ))
            }
        </div>
    );
}

export default UserList;